// 2023-03-25 09:57:46
import { GetConnection, GetResult } from '../../util/db.js'

class LoginService {
    /**
     * @param {[phone,password]} condition 一维数组
     * @returns {Promise<Boolean | result>} 对象:登录成功 false:登录失败
     */
    static async CheckUser(condition) {
        try {
            const conn = await GetConnection();
            let sql = "select * from usertable where isFreeze = 0 and phone = ? and password = ?";
            const {rows:result} = await GetResult(sql,condition,conn);
            if(result && result.length === 1){
                return result;
            }else return false;
        } catch (error) {
            return Promise.reject(error);
        }
    }
}

export default LoginService;
